<?php
define(CHECKOUT_STEP_STATE_INITIAL, 1);
define(CHECKOUT_STEP_STATE_ERROR, 2);
define(CHECKOUT_STEP_STATE_STANDBY, 3);
define(CHECKOUT_STEP_STATE_DONE, 4);

class CheckoutStep extends Error
{
    public $id;
    public $url='';
    public $name='';
    public $visible=true;
    public $description='';
    public $data=null;
    public $state;


    public function __construct($id, $options=array())
    {
        $this->id = $id;
        $this->url = $options['url']? $options['url'] : $this->url;
        $this->data = $options['data']? $options['data'] : $this->data;
        $this->name = $options['name']? $options['name'] : $this->name;
        $this->description = $options['description']? $options['description'] : $this->description;
        $this->visible = isset($options['visible'])? $options['visible'] : $this->visible;
        $this->state = $options['state']? $options['state'] : CHECKOUT_STEP_STATE_INITIAL;
    }


    public function getAHref()
    {
        if ($this->state == CHECKOUT_STEP_STATE_INITIAL)
            return "javascript: void(0);";
        else return $this->url;
    }


    public function getHTML($class)
    {
        $out = '';
        if ($this->visible!=false)
        {
            $out  = "<li class=\"". $class ."\">";
            $out .= '<a href="'. $this->getAHref() .'" title="">';
            $out .= '<em>'. htmlentities($this->name) .'</em>';
            $out .= '<span>'. htmlentities($this->description) .'</span></a></li>';
        }
        return $out;
    }
}

?>
